package com.stek.camera;

import android.hardware.Camera;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

import com.google.android.gms.ads.AdView;
import com.stek.R;
import com.stek.base.BaseOverLayActivity;
import com.stek.utils.AdMode;
import com.stek.utils.Utils;

public class TorchActivity extends BaseOverLayActivity {
	private Camera mCamera;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_torch);
		((ImageButton) findViewById(R.id.imgbtn_torch))
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						v.setSelected(!v.isSelected());
						Utils.CameraHardware.setFlashEnabled(
								getApplicationContext(), mCamera,
								v.isSelected());
					}
				});
		adView = (AdView) findViewById(R.id.admod);
		AdMode.init(adView);
		
	}

	@Override
	protected void onResume() {
		mCamera = Utils.CameraHardware.getBackCamera();
		((ImageButton) findViewById(R.id.imgbtn_torch)).performClick();
		super.onResume();
	}

	@Override
	protected void onPause() {
		Utils.CameraHardware.releaseCamera(mCamera);
		finish();
		super.onPause();
	}
}
